package com.api.department.getdocument;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.IDepartmentApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.DocumentApi;
import com.zyncro.api.model.ObjectResultApi;

@ContextConfiguration(locations = "classpath:/department/departments-toget.xml")
public class GetDocument extends AbstractApiTest {

	@Value("#{user_contact.appId}")
	private String userUrn;

	@Value("#{user_contact.password}")
	private String userPassword;

	@Value("#{department_toGet.urn}")
	private String iddepartment;

	@Value("#{department_toGet.fileUrn}")
	private String iddocument;

	@BeforeClass
	protected void loginUser() throws Exception {

		getApi().login(userUrn, userPassword);
	}

	@Test
	public void test() throws ZyncroApiException {
		ObjectResultApi<DocumentApi> result = getApi().getService(IDepartmentApiService.class).getDocument(iddepartment, iddocument);

		DocumentApi doc = result.getObject();

		Assert.assertEquals(doc.getUrn(), iddocument);
	}
}
